package com.example.demo1;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.codingapi.txlcn.tc.annotation.DTXPropagation;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author: yhb
 * @Date: Created in 2021/9/28 14:22
 * @Version:1.0
 */
@Service
public class BankService {

    @Resource
    private BankMapper bankMapper;
    @Transactional
    @LcnTransaction(propagation = DTXPropagation.REQUIRED) //分布式事务注解,发起方使用REQUIRED，事物参与方使用SUPPORTS
    public void add() {
        Bank bank = bankMapper.selectById(1);
        Integer money = bank.getMoney();
        bank.setMoney(money + 100);
        if(1==1){
            throw new RuntimeException("11");
        }
        bankMapper.updateById(bank);

    }
}
